package org.sunrise.game.common.network.start;

import org.sunrise.game.common.network.client.BaseClientManager;
import org.sunrise.game.common.network.message.BaseMessage;
import org.sunrise.game.common.utils.Utils;

public class TestClientStartUp {
    public static void main(String[] args) throws InterruptedException {
        var client1 = BaseClientManager.createBaseClient("client-node1");
        client1.connectBlock(Utils.getLocalIpAddress(), 1000);

        var client2 = BaseClientManager.createBaseClient("client-node2");
        client2.connectBlock(Utils.getLocalIpAddress(), 1001);

        var client3 = BaseClientManager.createBaseClient();
        client3.connectBlock(Utils.getLocalIpAddress(), 1002);


        for (int i = 0; i < 3; i++) {
            BaseMessage message = new BaseMessage(client1.getNodeId());
            message.setMsg(i);
            BaseClientManager.sendToServer(message);
        }

        for (int i = 3; i < 6; i++) {
            BaseMessage message = new BaseMessage(client2.getNodeId());
            message.setMsg(i);
            BaseClientManager.sendMsgToServer(message);
        }

        for (int i = 6; i < 9; i++) {
            BaseMessage message = new BaseMessage(client3.getNodeId());
            message.setMsg(i);
            BaseClientManager.sendMsgToServer(message);
        }
    }
}
